#include <jni.h>

int Fibonacci( int n )
{
    if ( n == 1 ) { return 1; }
    if ( n <= 0 ) { return 0; }

    return Fibonacci( n - 1 ) + Fibonacci( n - 2 );
}

#ifdef __cplusplus
extern "C" {
#endif

/*
 * Class:     com_nvidia_example_fibonacci_FibonacciActivity
 * Method:    Fibonacci
 * Signature: (I)I
 */
JNIEXPORT jint JNICALL Java_com_nvidia_example_fibonacci_FibonacciActivity_Fibonacci
  ( JNIEnv *env, jobject obj, jint n )
{
    return Fibonacci( n );
}

#ifdef __cplusplus
}
#endif
